Skip to content

Add Plotly custom mimetype to NB outputs. #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 20, 2017

Conversation

tarzzz
Copy link
Contributor

@tarzzz tarzzz commented Mar 15, 2017

Azure notebooks sanitize HTML when the user requests to 'Download as HTML'. This leads to Plotly Charts being rendered in plain text. To tackle the same, we send the Plotly chart data as a custom mimetype: text/vnd.plotly.v1+html.

PlotlyHTMLExporter (Plotly friendly, Jupyter Notebook HTML Exporter) recognizes this
mimetype, and renders the charts in their interactive version when notebook is converted to HTML.

PlotlyHTMLExporter sanitizes all html content but leaves Plotly Charts intact.

@tarzzz
Copy link
Contributor Author

tarzzz commented Mar 15, 2017

@Kully Please review..
cc: @chriddyp

'text/html': script_inject,
'text/vnd.plotly.v1+html': script_inject
}
ipython_display.display(display_bundle, raw=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why raw=True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kully :

From IPython Docs:

raw : bool
Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

We dont want IPython to do any further processing on this, so we use raw=True.

@Kully
Copy link
Contributor

Kully commented Mar 15, 2017

@tarzzz Okay Tarun, it's clearer now how this is supposed to work based on the code. Just have that one comment but the rest looks fine to me.

@tarzzz
Copy link
Contributor Author

tarzzz commented Mar 15, 2017

@Kully : We will also need to release a new version for this change, so that the users can do a pip upgrade and be able to use it with plotlyhtmlexporter. How should I do that?

@cldougl
Copy link
Member

cldougl commented Mar 15, 2017

@tarzzz you can update the changelog and version and we'll release on pip

@tarzzz
Copy link
Contributor Author

tarzzz commented Mar 20, 2017

@cldougl : Updated Changelog and version .. 👍

@cldougl
Copy link
Member

cldougl commented Mar 20, 2017

lgtm 💃 after tests pass

@tarzzz tarzzz merged commit 1389703 into master Mar 20, 2017
@tarzzz
Copy link
Contributor Author

tarzzz commented Mar 20, 2017

Great, merging!! 🎉

@tarzzz tarzzz deleted the custom-plotly-mimetype-to-outputs branch March 20, 2017 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants